<template>
  <div class="header">
    <el-dropdown>
      <i class="el-icon-user-solid" style="margin-right: 15px"></i>
      <el-dropdown-menu slot="dropdown">
        <!-- <el-dropdown-item>查看</el-dropdown-item> -->
        <el-dropdown-item>
          <span @click="quit">退出</span>
        </el-dropdown-item>
        <!-- <el-dropdown-item>删除</el-dropdown-item> -->
      </el-dropdown-menu>
      <span>{{username}}</span>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  props: {},
  data() {
    return {};
  },
  computed: {
    username: function() {
      if (JSON.parse(sessionStorage.getItem("userinfo"))&& JSON.parse(sessionStorage.getItem("userinfo")).id.toString() !="null") {
        return JSON.parse(sessionStorage.getItem("userinfo")).name;
      } else {
        this.$router.push({ path: "/login" });
      }
    }
  },
  created() {},
  mounted() {},
  watch: {},
  methods: {
    quit() {
      // console.log(2333)
      this.$router.push({ path: "/login" });
      sessionStorage.clear();
    }
  },
  components: {}
};
</script>

<style scoped lang="less">
.header {
  padding: 20px 60px 20px 0;
  font-size: 16px;
}
</style>
